define(function (require, exports, module) {
    var template = require("template");
    var Ajax = require("ajax");
    var layer = require("layer");
    var pagination = require('pagination');
    var util = require('util');
    
    var searchObj = function (callback) {
        this.init.apply(this,arguments);
    };
    searchObj.prototype = {
        constructor: searchObj,
        options: {},
        init: function (options) {
            var t = this;
            t.options = $.extend({},t.options,options);
            $(".tipConNav").text("中周搜索");
            $(window).off('scroll');
            $("#rightConBox").html(template("monitorSearchTemp",{}));
            $("#articleType").val("");
            t.mask();
            t.loadInitList();
        },
        mask: function(){
            $(".mask").css("height",$(document).height());
            $(".mask").css("width",$(document).width());
        },
        
        loadInitList: function() {
			var t = this;
			var paramsObj = {
				articleType:"",
				title:""
			}
			$("#ul_select li a").on('click',function(){
                var $type = $(this);
                if(!$type.hasClass("cur")){
                    $("#ul_select li a").removeClass("cur");
                }
                $type.addClass("cur");
                $("#articleType").val($(".cur").attr("data-key"));
                
			});
			$(".searchBtn").on('click',function(){
				$.cookie("articleTypesText",$("#articleType").val());
				$.cookie("contentsText",$("#search_input").val()?$("#search_input").val().trim():null);
				$.cookie("wayspanText",$(".wayspan .checked").attr("data-key"));
				window.location.href = "#!admin/monitor_screen";
			});
            //键盘“enter”搜索
            $("#search_input").keydown(function(event) {
                if (event.keyCode == "13") {//keyCode=13是回车键
    				$.cookie("articleTypesText",$("#articleType").val());
    				$.cookie("contentsText",$("#search_input").val()||null);
    				window.location.href = "#!admin/monitor_screen";
                }
            });
			$('.waySelect .iconfont').on('click',function(){
            	if(!$(this).hasClass('checked')){
            		$(this).removeClass('icon-fangxingweixuanzhong').addClass('icon-check').addClass('checked');
            		$(this).parent().siblings().children('i').removeClass('checked').removeClass('icon-check').addClass('icon-fangxingweixuanzhong');
            	}
            });
		}
    };
    module.exports = searchObj;
});

